﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace SW.EF.DAL
{
    public interface IRepository<TEntity, in TKey> : IDisposable where TEntity : class 
    {
        IQueryable<TEntity> Query();
        IQueryable<TEntity> Filter(Expression<Func<TEntity, bool>> predicate);
        Tuple<IQueryable<TEntity>, int> Filter(Expression<Func<TEntity, bool>> predicate, int page, int pageSize);
        TEntity Find(TKey key);
        TEntity Find(Expression<Func<TEntity, bool>> predicate);
        int Count();
        TEntity Save(TEntity model, bool isSave = true);
        TEntity Update(TEntity model, bool isSave = true);
        int Delete(TEntity model, bool isSave = true);
        int Delete(Expression<Func<TEntity, bool>> predicate, bool isSave = true);
    }
}
